package com.rds.benchmark.util;

public class MakeValue {

    public static long num = 0;

    public static String value = "value-"
            + "123456789012345678901234567890123456789012345678901234567890"
            + "123456789012345678901234567890123456789012345678901234567890"
            + "123456789012345678901234567890123456789012345678901234567890"
            + "123456789012345678901234567890123456789012345678901234567890";

    public static void make(String valueLength) {
        if (valueLength == null || "".equals(valueLength)) {
            throw new IllegalArgumentException("Value length is not num!!!");
        }

        int length = Integer.parseInt(valueLength);
        if (length < 1) {
            throw new IllegalArgumentException("Value length is < 1");
        }
        int runCir = 0;
        int modulo = 0;
        if (length > 6) {
            //计算value length 设置的除了6个固定位之外有几个10
            runCir = (length - 6) / 10;
            modulo = (length - 6) % 10;
        }

        StringBuffer stringBuffer = new StringBuffer();

        char[] valueMates = "value-".toCharArray();

        for (int i = 0; i < length; i++) {
            if (i < 6) {
                //拼接6个固定位中的内容 value-
                stringBuffer.append(valueMates[i]);
            } else {
                if (runCir > 0 && ((i - 5) % 10 == 0)) {
                    //除了6个固定位之外,每10次append一次
                    stringBuffer.append("0123456789");
                }
            }
        }
        //拼接除了6个固定位+10整数位之外,不满10的长度
        for (int i = 0; i < modulo; i++) {
            stringBuffer.append(i);
        }

        value = stringBuffer.toString();
    }
}
